package com.chalk.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.chalk.model.VenueAndSe;
import com.chalk.dao.VenueAndSeDao;
import com.chalk.service.VenueAndSeService;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author glq
 * @since 2020-12-10
 */

@Service
public class VenueAndSeServiceImpl extends ServiceImpl<VenueAndSeDao, VenueAndSe> implements VenueAndSeService {

    @Override
    public int addVenueAndSe(VenueAndSe entity) {
        return baseMapper.insert(entity);
    }

    @Override
    public int updateVenueAndSe(VenueAndSe entity) {
        return baseMapper.updateById(entity);
    }


    @Override
    public int deleteVenueAndSe(Integer id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public List<Integer> getVenuesBySeId(Integer seId) {
        List<Integer> integerList = new ArrayList<>();
        //添加构造
        EntityWrapper<VenueAndSe> wrapper = new EntityWrapper<>();
        wrapper.eq("se_id", seId);
        List<VenueAndSe> list = selectList(wrapper);
        //过滤到Integer集合
        for (VenueAndSe v : list) {
                integerList.add(v.getVenueId());
        }

        return integerList;
    }

    @Override
    public List<Integer> getSportEventsByVenueId(Integer venueId) {
        List<Integer> integerList = new ArrayList<>();
        //添加构造
        EntityWrapper<VenueAndSe> wrapper = new EntityWrapper<>();
        wrapper.eq("venue_id", venueId);
        List<VenueAndSe> list = selectList(wrapper);
        //过滤到Integer集合
        for (VenueAndSe v : list) {
            integerList.add(v.getSeId());
        }
        return integerList;
    }
}
